﻿#region Apache 2.0 License header

//   Copyright 2012 Lesley van Zijl
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License. 

#endregion

using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;

namespace Tests.Helpers
{
    public class TargetTestClass
    {
        private static MethodInfo _fieldStaticReferenceType;
        private static int _fieldStaticValueType = 90;
        private MethodInfo _fieldReferenceType = new DynamicMethod("F", typeof (int), null);
        private int _fieldValueType = 5;
        private MethodInfo PropertyReferenceTypeGetSet { get; set; }

        private MethodInfo PropertyReferenceTypeGet
        {
            get { return new DynamicMethod("F", typeof (int), null); }
        }

        private MethodInfo PropertyReferenceTypeSet
        {
            set { }
        }

        private int PropertyValueTypeGetSet { get; set; }

        private int PropertyValueTypeGet
        {
            get { return 5; }
        }

        private int PropertyValueTypeSet
        {
            set { }
        }

        private static MethodInfo PropertyStaticReferenceTypeGetSet { get; set; }

        private static MethodInfo PropertyStaticReferenceTypeGet
        {
            get { return new DynamicMethod("F", typeof (double), null); }
        }

        private static MethodInfo PropertyStaticReferenceTypeSet
        {
            set { }
        }

        private static int PropertyStaticValueTypeGetSet { get; set; }

        private static int PropertyStaticValueTypeGet
        {
            get { return 29; }
        }

        private static int PropertyStaticValueTypeSet
        {
            set { }
        }

        public int PublicStaticValueTypeField { get; set; }
        public int PublicValueTypeField { get; set; }
        public MethodInfo PublicStaticReferenceTypeField { get; set; }
        public MethodInfo PublicReferenceTypeField { get; set; }

        protected int ProtectedStaticValueTypeField { get; set; }
        protected int ProtectedValueTypeField { get; set; }
        protected MethodInfo ProtectedStaticReferenceTypeField { get; set; }
        protected MethodInfo ProtectedReferenceTypeField { get; set; }

        internal int InternalStaticValueTypeField { get; set; }
        internal int InternalValueTypeField { get; set; }
        internal MethodInfo InternalStaticReferenceTypeField { get; set; }
        internal MethodInfo InternalReferenceTypeField { get; set; }

        #region Special method args methods

        private void OutArgMethod(out MethodInfo methodInfo)
        {
            methodInfo = new DynamicMethod("F2", null, Type.EmptyTypes);
        }

        private void RefArgMethod(ref MethodInfo methodInfo)
        {
            methodInfo = null;
        }

        private void RefArrayArgMethod(ref MethodInfo[] methodInfo)
        {
            methodInfo[0] = null;
        }

        private void RefArgValueTypeMethodInt32(ref int number)
        {
            number = 16;
        }

        private void RefArgValueTypeMethodUInt32(ref UInt32 number)
        {
            number = 16;
        }

        private void RefArgValueTypeMethodInt16(ref Int16 number)
        {
            number = 16;
        }

        private void RefArgValueTypeMethodUInt16(ref UInt16 number)
        {
            number = 16;
        }

        private void RefArgValueTypeMethodInt64(ref Int64 number)
        {
            number = 16;
        }

        private void RefArgValueTypeMethodUInt64(ref UInt64 number)
        {
            number = 16;
        }

        private void RefArgValueTypeMethodChar(ref Char c)
        {
            c = '3';
        }

        private void RefArgValueTypeMethodByte(ref Byte number)
        {
            number = 16;
        }

        private void RefArgValueTypeMethodSByte(ref SByte number)
        {
            number = 16;
        }

        private void RefArgValueTypeMethodDouble(ref Double number)
        {
            number = 16.0d;
        }

        private void RefArgValueTypeMethodSingle(ref Single number)
        {
            number = 16.0f;
        }

        private void RefArgValueTypeMethodGuid(ref Guid guid)
        {
            guid = Guid.Empty;
        }

        private void RefArgValueTypeMethodBoolean(ref Boolean b)
        {
            b = true;
        }

        private void RefArgValueTypeMethodDecimal(ref Decimal d)
        {
            d = 67;
        }


        private void ParamsValueArgMethod(params int[] p)
        {
        }

        private void ParamsReferenceArgMethod(params MethodInfo[] methodInfos)
        {
        }

        private void OutAndRefArgMethod(ref MethodInfo miRef, out MethodInfo miOut)
        {
            miOut = miRef;
        }

        #endregion

        private Guid MethodGuidArg(ref Guid guid)
        {
            return Guid.Empty;
        }

        private int MethodValueReturn()
        {
            return 5;
        }

        private MethodInfo MethodReferenceReturn()
        {
            return new DynamicMethod("F", typeof (double), Type.EmptyTypes);
        }

        private void Method()
        {
        }

        private static void MethodStatic()
        {
        }

        private void Method1ParameterReferenceType(MethodInfo methodInfo)
        {
        }

        private void Method2ParamaterReferenceType(MethodInfo methodInfo, StringBuilder stringBuilder)
        {
        }

        private void Method1ParameterValueType(int i)
        {
        }

        private void Method2ParameterValueType(int i, float f)
        {
        }

        private int MethodValueTypeArray(int[] ints)
        {
            int result = 0;

            foreach (int i in ints)
            {
                result += i;
            }

            return result;
        }

        private void MethodReferenceTypeArray(MethodInfo[] methods)
        {
        }

        private void Method2Arrays(int[] ints, MethodInfo[] methods)
        {
        }

        private void MethodOverload()
        {
        }

        private void MethodOverload(int i)
        {
        }

        private void MethodOverload(int i, double d)
        {
        }

        private void MethodOverload(int i, MethodInfo mi)
        {
        }

        private void MethodOverload(MethodInfo mi)
        {
        }
    }
}